package com.gylang.crypto.controller;

import com.gylang.api.core.domain.AjaxResult;
import com.gylang.crypto.annotation.CryptoRequest;
import com.gylang.crypto.annotation.CryptoResponse;
import com.gylang.crypto.enums.CommonCryptoKey;
import com.gylang.crypto.enums.CryptoStrategyEnum;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * 简单测试加解密controller
 * @author gylang
 * data 2020/10/27
 * @version v0.0.1
 */
@RestController
@RequestMapping("methodResolver")
@RequiredArgsConstructor
public class CustomAnnotationController {

    @RequestMapping("test")
    @CryptoResponse(type = CryptoStrategyEnum.AES, encryptKey = CommonCryptoKey.AES_KEY)
    public AjaxResult<Map<String, String>> methodResolver(@CryptoRequest(type = CryptoStrategyEnum.AES, decryptKey = CommonCryptoKey.AES_KEY)
                                             Map<String, String> request) {
        return AjaxResult.success(request);

    }
}
